﻿@{
    var cartItem = new CartItemViewModel();
}

<template id="cart-item-form">
    <form class="center-block" data-bind="submit:upsertCartItem">
        <div class="form-group">
            <!-- ko if:cartItem.id === undefined -->
            @Html.LabelFor(m => cartItem.Quantity)
            <!-- /ko -->
            <div class="input-group form-group-sm">
                <div class="col-sm-8">
                    @Html.TextBoxFor(m => cartItem.Quantity, new { data_bind = "textInput:cartItem.quantity", @class = "form-control" })
                    @Html.ValidationMessageFor(m => cartItem.Quantity, "", new { @class = "text-danger" })
                </div>
            </div>
        </div>
        @*<div class="form-group" data-bind="isDirty:cartItem.quantity">*@
        <div class="form-group">
            <button type="submit" class="btn btn-primary" data-bind="visible:!sending(),text:cartItem.id===undefined?'加入购物车':'更新'"></button>
        </div>
    </form>
    <div class="progress" data-bind="visible:sending">
        <div class="progress-bar progress-bar-info progress-bar-striped active"
             role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width:100%;">
            <span class="sr-only"></span>
        </div>
    </div>
</template>